package com.cxs.xiaomi.dao.impl;

import com.cxs.xiaomi.dao.OrderDetailDao;
import com.cxs.xiaomi.domain.OrderDetail;
import cxs.utils.handler.impl.ResultHandlerAsListImpl;
import cxs.utils.templete.JdbcTemplete;

import java.util.List;

/*
 * @Author:cxs
 * @Date:2021/9/17  9:55
 * @Version 1.0
 * @Motto:放下杂念,只为迎接明天更好的自己
 * */
public class OrderDetailDaoImpl implements OrderDetailDao {
    @Override
    public int insert(OrderDetail orderDetail) {
        String sql = "insert into tb_orderdetail values(null,?,?,?,?)";
        Object[] arrs = {orderDetail.getOid(),orderDetail.getPid(),orderDetail.getNum(),orderDetail.getMoney()};
        return JdbcTemplete.DMLTemplete(sql,arrs);
    }

    @Override
    public List<OrderDetail> selectByOid(String oid) {
        String sql = "select * from tb_orderdetail where Oid = ?";
        return JdbcTemplete.DQLTemplete(sql,new ResultHandlerAsListImpl<>(OrderDetail.class),oid);
    }
}
